package com.blog.controller.admin;

import com.blog.dto.ExperienceDTO;
import com.blog.entity.Experience;
import com.blog.result.Result;
import com.blog.service.ExperienceService;
import com.blog.vo.CategoryVO;
import com.blog.vo.ExperienceVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminExperienceController")
@RequestMapping("/admin/Experience")
@Slf4j
public class ExperienceController {

    @Autowired
    private ExperienceService experienceService;


    @GetMapping("/listByUId")
    public Result<List<ExperienceVO>> ListByUIdExperience(){
        log.info("根据用户ID查询工作经历.....");
        List<ExperienceVO> list = experienceService.listByUId();
        return Result.success(list);
    }
    @GetMapping("/getOneExperienceById/{EId}")
    public Result<ExperienceVO> getOneExperienceById(@PathVariable("EId") Long EId){
        log.info("根据用户ID查询工作经历.....");
        ExperienceVO experienceVO = experienceService.getOneExperienceById(EId);
        return Result.success(experienceVO);
    }

    @GetMapping("/listByTitel/{titelInfo}")
    public Result<List<ExperienceVO>> ListByTitelExperience(@PathVariable("titelInfo") String value){
        log.info("根据用户IDh和岗位名称查询工作经历.....");
        List<ExperienceVO> list = experienceService.listByTitel(value);
        return Result.success(list);
    }

    @PostMapping("/AddExperience")
    public Result AddExperience(@RequestBody ExperienceDTO experienceDTO){
        log.info("添加工作经历：{}",experienceDTO);
        experienceService.AddExperience(experienceDTO);
        return Result.success();
    }

    @PutMapping("/EditExperience")
    public Result EditExperience(@RequestBody ExperienceDTO experienceDTO){
        log.info("修改工作经历：{}",experienceDTO);
        experienceService.EditExperience(experienceDTO);
        return Result.success();
    }


    @DeleteMapping("/DelExperience/{id}")
    public Result DelExperience(@PathVariable("id") Long id){
        log.info("删除工作经历：{}",id);
        experienceService.DelExperience(id);
        return Result.success();
    }
}
